'''
测试一个经典GUI程序的写法，使用面向对象的方式
'''

from tkinter import *
from tkinter import messagebox

class Application(Frame):

    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()
        self.createEidget()

    def createEidget(self):
        '''创建组件'''
        self.btn01 = Button(self)
        self.btn01["text"] = '点我送花'
        self.btn01.pack()
        self.btn01["command"] = self.songhua

        '''
        点击退出
        destroy退出这个程序
        '''
        self.butQuit = Button(self,text="退出",command = self.master.destroy)
        self.butQuit.pack()

    def songhua(self):
        messagebox.showinfo("送花","送你999朵玫瑰花")



if __name__ == '__main__':
    root = Tk()
    root.geometry("400x100+200+300")
    root.title("一个经典的GUI")
    app = Application(master=root)
    root.mainloop()